package cn.bdqn.tangcco.user.controller;

import cn.bdqn.tangcco.entity.Tbuser;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.view.InternalResourceViewResolver;

import javax.servlet.http.HttpSession;

/**
 * Created by Administrator on 2016/5/31.
 */
@Controller
public class LoginController {


    @RequestMapping(value = "/loginController",method = RequestMethod.POST)
    public String login(Tbuser users, HttpSession session, Model model){
        String forward= "";

        if("admin".equals(users.getUsername())&&"1234".equals(users.getPassword())){
            Tbuser u = new Tbuser();
            u.setUsername("管理员");
            session.setAttribute("users", u);
            forward = "main/main";
        }else{
            model.addAttribute("msg", "对不起，用户名或者密码错误!");
            forward = InternalResourceViewResolver.FORWARD_URL_PREFIX+"/index.jsp";
        }


        return forward;
    }





}
